import uniCrazyRouter from "@/node_modules/uni-crazy-router/dist/index.js"
import store from '@/store'

function bindInterceptTabBar() {
	// 自定义tabbar跳转到tabbar栏改变current值，正常UNI跳转免携带参数
	return uniCrazyRouter.beforeEach(async (to, from, next) => {
		let pathList = store.state.tabBarList
		let toUrl = '/' + to.url
		for (let i = 0; i < pathList.length; i++) {
			if (toUrl == pathList[i].path) {
				store.commit('updateCurrent', i)
			}
		}
		next()
	})
}
export default bindInterceptTabBar
